<?php


namespace App\Http\Controllers\Sale;

use App\Http\Controllers\Controller;
use App\Models\SaleUser;
use App\Services\CommonService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Redis;

class BaseExportController extends Controller
{
    protected $users;
    protected $sale_user;
    //过滤验证 [目录\controller@action]
    protected $filterAction = [
//        'Supplier\LoginController@login',
    ];

    public function __construct(Request $request)
    {
        // parent::__construct($request);
        $userToken = $request->input("SaleAuth");
        $user = json_decode(Redis::get($userToken),true);
        // dd($user);
        if($user){
            if($user['is_show'] == CommonService::SHOP_DISABLE){
                //删除
                echo json_encode(['status' => CommonService::HTTP_CODE_FAIL, 'msg' => '账号不存在', 'data' => []],JSON_UNESCAPED_UNICODE);exit;
            }
            $sale_user = SaleUser::where('sale_user_id',$user['sale_user_id'])->select('level')->first();

            $this->users = $user;
            $this->sale_user = $sale_user;
            return true;
        }
        echo json_encode(['status' => CommonService::HTTP_CODE_NOT_LOGIN, 'msg' => '请登录', 'data' => []],JSON_UNESCAPED_UNICODE);exit;
    }




}
